
import AdManager, { Platform } from "../../../Platforms/AdManager";
import { FormType } from "../../../UIFrame/config/SysDefine";
import UIBase from "../../../UIFrame/UIBase";
import UIManager from "../../../UIFrame/UIManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class HuaWeiAdUI extends UIBase {

    formType = FormType.PopUp;

    static prefabPath = "prefabs/UIForms/adUI/HuaweiAdUI";

    onShow(type) {

        AdManager.getInstance().platform = Platform.huawei_H5;
        AdManager.getInstance().onInit(() => { });
    }

    onLoad() {
    }

    start() {

    }

    async showAnimation() {
        console.log('重写打开动画');
    }

    onClickEvent_openBanner() {
        AdManager.getInstance().showBanner('banner', 'bannerOpenId');
    }

    onClickEvent_openInsert() {
        AdManager.getInstance().showInsertAd('insert', 'insertOpenId');
    }

    onClickEvent_openVideo() {
        AdManager.getInstance().showVideo('video', () => {
            console.log('成功回调');
        }, () => {
            console.log('失败回调');
        });
    }

    onClickEvent_openNativeAd(e: cc.Event.EventTouch, type) {
        let adIdKey = '';
        if (type == '1') {
            adIdKey = 'banner';
        } else if (type == '2') {
            adIdKey = 'insert';
        }
        AdManager.getInstance().showNativeAd(adIdKey, (_res) => {
            if (type == '1') {
                UIManager.getInstance().openUIForm('prefabs/UIForms/ad/NativeBanner', _res);
            } else if (type == '2') {
                UIManager.getInstance().openUIForm('prefabs/UIForms/ad/NativeInsert', _res);
            } else {
                //自己界面上的ui 渲染,渲染方法参考上面的
            }
        });
    }

    onClickEvent_addDesktop() {
        AdManager.getInstance().addDesktop((res) => {
            if(res ==1){
                console.log('分享==>成功');
            }else if(res == 0){
                console.log('分享==>失败');
            }
        });
    }

    onHide() {

    }
}
